<?php
/***********************************************************************

  Copyright (C) 2008  Fabrice douteaud (fdouteaud@gmail.com)

    This file is part of ClearBudget.

    ClearBudget is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    ClearBudget is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar.  If not, see <http://www.gnu.org/licenses/>.


************************************************************************/

$db = class_db::getInstance();

$json = 1;
isset($_GET['id'])?$id = $_GET['id']:$id = null;
$id = explode('-', $id);
// the category id
$categoryId = $id[1];
// the item id
$itemId = $id[0];
// the comment
isset($_GET['comment'])?$comment = $_GET['comment']:$comment = null;

$success = false;
// update the record if necessary (we have an ID, a Category and maybe a Comment)
if($categoryId != null && $id != null) {
  $db->addFields('category', $categoryId);
  //if($comment != null) $db->addFields('comments', $comment);
  $db->addFields('comments', $comment);
  $db->addWhere('id', '=', $itemId);
  $db->update('t_items');
  $success = true;
  }

// next action
$action = false;

// HTML to be loaded
$snippet = 'itemEditSubmit';
?>